package com.example.kotlindemo_room

import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData

class StudentViewModel(application: Application) :
    AndroidViewModel(application) {

     var studentRepository: StudentRepository? = null

//
    init {
        this.studentRepository = StudentRepository(application)
    }


    fun InsertStuDent() {
        studentRepository?.InsertStuDent()
    }
    fun InsertStuDent2(student: Student) {
        studentRepository?.InsertStuDent2(student)
    }

    fun DeleteStuDent(student: Student) {
        studentRepository?.DeleteStuDent(student)
    }

    fun UpDateStuDent(student: Student) {
        studentRepository?.UpDateStuDent(student)
    }

    fun DeleteAllStuDent() {
        studentRepository?.DeleteAllStuDent()
    }


    fun getAllStuDentLive(): LiveData<List<Student>>? {
        return  studentRepository?.getAllStuDent()
    }


}